home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #6 / Amiga Plus CD - 2004 - No. 06.iso / AmigaPlus / Begleitmaterial / 50Tools / Grafik / PerfectPaint / rexx / general / SaveAnimGif.rx < prev    next >
Text File  |  2003-06-26  |  4KB  |  208 lines

  1. /*     arexx Script 
  2.     SAVE Anim in GIF format
  3.     need in 'PerfectPaint/tools':
  4.     - tapgif
  5.     - WhirlGif
  6. */
  7.  
  8.     options results
  9.     parse ARG Port b
  10.     
  11.     ADDRESS value Port
  12.        options results
  13.  
  14.     pp_CountFrames
  15.     nb=result
  16.     if nb<2 then do
  17.         pp_Warn 'Make*an*Anim*first.'
  18.         EXIT
  19.     end
  20.  
  21.     file=""
  22.     file2=""
  23.     option=0
  24.     option2=0
  25.     if EXISTS('PerfectPaint:Prefs/Rexx_Prefs/SaveAnimGif') THEN DO
  26.         IF OPEN('lfile','PerfectPaint:Prefs/Rexx_Prefs/SaveAnimGif', "R") then DO
  27.             file = READLN('lfile')
  28.             option=READLN('lfile')
  29.             option2=READLN('lfile')
  30.             CALL CLOSE('lfile')
  31.             file2=""
  32.             do i=1 to LENGTH(file)
  33.                 a=SUBSTR(file,i,1)
  34.                 if a=" " then DO
  35.                     a="*"
  36.                 END
  37.                 file2=file2||a
  38.             END
  39.             file=file2
  40.         END
  41.     END
  42.  
  43.     pp_GetDepth
  44.     D=result
  45.     IF D=24 then DO
  46.         pp_RenderReq 1
  47.     END
  48.  
  49.     pp_DialogInit 250 100 "*Save*AnimGif*" 4
  50.         pp_String 0 55 8 150 16 "Name" 1 100 file
  51.  
  52.         n=LASTPOS('/',file)
  53.         if n=0 then DO
  54.             n=LASTPOS(':',file)
  55.             file=SUBSTR(file,1,n)
  56.         END
  57.         else DO            
  58.             file=SUBSTR(file,1,n)
  59.         END
  60.  
  61.         pp_Getfile 1 210 9 0 "Save*AnimGif" 0 file
  62.         pp_Cycle 2 105 28 100 16 "Transparency" 1 "No|Color*0|Current*Bg" option
  63.         pp_Cycle 3 105 48 100 16 "Disposal*method" 1 "None|Not|Background|Previous" option2
  64.     pp_Dialog        
  65.  
  66.     rc=result
  67.     if rc=0 then
  68.         do
  69.             EXIT
  70.         end    
  71.  
  72.     pp_GetDialog 0
  73.     file=result
  74.     IF file="" then DO
  75.         EXIT
  76.     END
  77.  
  78.     file2='PerfectPaint:temp/temp'
  79.  
  80.     pp_GetDialog 2
  81.     option=result
  82.  
  83.     pp_GetDialog 3
  84.     option2=result
  85.  
  86.     CALL SavePrefs('SaveAnimGif',file,option,option2)
  87.     ADDRESS value Port
  88.  
  89.     if option2=0 then
  90.     DO
  91.     dispose='none'
  92.     END
  93.  
  94.     if option2=1 then
  95.     DO
  96.     dispose='not'
  97.     END
  98.  
  99.     if option2=2 then
  100.     DO
  101.     dispose='back'
  102.     END
  103.  
  104.     if option2=3 then
  105.     DO
  106.     dispose='prev'
  107.     END
  108.  
  109.     if option=2 then
  110.     DO
  111.         pp_GetBpen
  112.         Bpen=result
  113.     END
  114.  
  115.     if option=1 then
  116.     DO
  117.         Bpen=0
  118.     END
  119.  
  120.     pp_GotoFrame 1
  121.     pp_GetJiffies
  122.     jiffies=result*2
  123.     filetemp="ram:temp"
  124.  
  125.     ii=''
  126.     IF D=24 then DO
  127.         pp_Render 2 'PerfectPaint:Temp/temp'
  128.         CALL OPEN(out,filetemp,write)
  129.         pp_asay 'Making*GIF*picture|Please*wait*...'
  130.         Do i=1 to nb
  131.             ii=i
  132.             IF i<1000 then DO
  133.                 ii='0'||i
  134.                 IF i<100 then DO
  135.                     ii='00'||i
  136.                     IF i<10 then DO
  137.                         ii='000'||i
  138.                     END
  139.                 END
  140.             END
  141.             address COMMAND
  142.             'perfectpaint:tools/tapgif '||'PerfectPaint:Temp/temp'||ii||' '||'PerfectPaint:Temp/temp.'||ii
  143.             CALL WRITELN(out,'PerfectPaint:Temp/temp.'||ii)                        
  144.         END    
  145.         ADDRESS value Port
  146.         pp_CloseAsay
  147.     END
  148.  
  149.     IF D<24 then DO
  150.         pp_asay 'Saving*GIF*file|Please*wait*...'
  151.         CALL OPEN(out,filetemp,write)
  152.         DO i=1 to nb
  153.             pp_GotoFrame i    
  154.             pp_save 't:pptemp' 0
  155.             file3=file2||i
  156.             address COMMAND
  157.             'perfectpaint:tools/tapgif '||'t:pptemp '||'"'||file3||'"'
  158.             'delete >nil: t:pptemp'
  159.             CALL WRITELN(out,file3)
  160.             ADDRESS value Port
  161.         END        
  162.         pp_CloseAsay
  163.     END
  164.  
  165.     pp_asay 'Making*Animation|Please*wait*...'
  166.  
  167.     address COMMAND
  168.     CALL CLOSE(out)
  169.  
  170.     if option=0 then
  171.     DO
  172.     'perfectpaint:tools/WhirlGif -time '||jiffies||' -o '||'"'||file||'"'||' -loop '||'-disp '||dispose||' -i ram:temp'    
  173.     END
  174.     ELSE
  175.     DO
  176.     'perfectpaint:tools/WhirlGif -time '||jiffies||' -o '||'"'||file||'"'||' -loop -trans '||Bpen||' -disp '||dispose||' -i ram:temp'
  177.     END
  178.     'delete >nil: PerfectPaint:Temp/?#.*'
  179.  
  180.     ADDRESS value Port
  181.     pp_SaveIconFor file 2
  182.     pp_CloseAsay
  183.  
  184.     address COMMAND
  185.     'delete >nil: ram:temp'
  186.  
  187.     EXIT
  188.     
  189.  
  190.  
  191. SavePrefs: PROCEDURE
  192.     
  193.     Prefname='PerfectPaint:Prefs/Rexx_Prefs/'||ARG(1)
  194.  
  195.     if EXISTS(Prefname) THEN DO
  196.         ADDRESS COMMAND
  197.         'delete >nil: '||Prefname
  198.     END
  199.  
  200.     IF OPEN('pfile',PrefName,'W') THEN DO
  201.  
  202.     do i=2 to ARG()
  203.         CALL WRITELN('pfile',ARG(i))
  204.     end
  205.  
  206.     CALL CLOSE('pfile')
  207.  
  208. RETURN